<?php

require_once 'searchInterfaces/boatSearch.php';
require_once 'searchInterfaces/nameSearch.php';
require_once 'searchInterfaces/ageSearch.php';
require_once 'models/advancedSearch.php';


class AdvancedSearchController {
    
    private $m_searchModel;
    
    /**
     * @param SearchModel $searchModel
     */
    public function __construct(SearchModel $a_searchModel) {
        $this -> m_searchModel = $a_searchModel;
        //$this -> m_searchViewer = new searchView();
    }
    
    function doControll() {
        
        $advancedSearch1 = new AdvancedSearch() ;
        
        $advancedSearch1->add(new nameSearch("user", nameSearch::EQUAL)) ;
        $advancedSearch1->add(new nameSearch("testuser", nameSearch::EQUAL), "OR") ;

        $advancedSearch2 = new AdvancedSearch() ;
        
		$advancedSearch2->add(new ageSearch("20", ageSearch::GREATER)) ;
        $advancedSearch2->add($advancedSearch1, "OR") ;
        $advancedSearch2->add(new boatSearch("Segelbåt", boatSearch::EQUAL)) ;
		
        var_dump($this->m_searchModel->search($advancedSearch2));
        
        
    }
    
}
